package ai.restosuite.infrastructure.operation.listen;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.Expression;
import org.camunda.bpm.engine.delegate.JavaDelegate;

public class ExecutionListener implements JavaDelegate {

    private Expression processType;
    @Override
    public void execute(DelegateExecution delegateExecution) throws Exception {
        // 获取发起用户
        String userName = (String) delegateExecution.getVariable("startUser");
        //获取监听自定义参数
        String type = (String) processType.getValue(delegateExecution);

        if("start".equals(type)){
            //发送邮件通知:流程发起通知
            System.out.println("--------流程发起通知-------:"+userName + "审批任务链接：http://localhost:8080/camunda/app/tasklist" + "实例id:"+delegateExecution.getProcessInstanceId());
        }else if("end".equals(type)){
            //发送邮件通知:流程结束通知
            System.out.println("--------流程结束通知-------:"+userName);
        }
    }
}
